declare boundary-space preserve;

(: 
Part 2 / Q3
For each question in the question bank, the content of the question text and 
the content of the correct answer.
:)

for $question in fn:doc("bank.xml")/QuestionBank/Question
return
    if ((local-name($question/*) eq "TFQuestion") 
        or (local-name($question/*) eq "NumericQuestion")) 
    then (
        <Item>
            <Question>{data($question/*/Text)}</Question>
            <Answer>{data($question/*/@answer)}</Answer>
        </Item>
        )
    else (
        <Item>
            <Question>{data($question/*/Text)}</Question>
            <Answer>{data($question/*/OptionList/Option[xs:integer($question/*/@answer)])}</Answer>
        </Item>
        )

